package com.zd.kids.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.hyy.libray.presenter.IBasePresenter;
import com.hyy.libray.ui.activity.BaseActivity;
import com.zd.kids.R;
import com.zd.kids.net.HttpMethod;

import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class InputMobileActivity extends BaseActivity {
    @BindView(R.id.ed_input_mobile)
    EditText edInputMobile;
    @BindView(R.id.tv_area)
    TextView tvArea;

    /**
     * 获取布局文件地址
     */
    @Override
    public int getLayoutResId() {
        return R.layout.activity_input_mobile;
    }

    /**
     * 初始化布局
     */
    @Override
    public void initView() {
        initTitle(getString(R.string.login_qm));
    }

    /**
     * 获取Presenter，不用MVP，可以为空
     *
     * @return
     */
    @Override
    protected IBasePresenter onBasePresenter() {
        return null;
    }


    @OnClick({R.id.tv_area, R.id.tv_confirm})
    public void onViewClicked(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.tv_area:
                intent = new Intent(this, SelectCityActivity.class);
                startActivityForResult(intent, SelectCityActivity.SELECT_RESULT_CODE);
                break;
            case R.id.tv_confirm:
                intent = new Intent(this, InputCodeActivity.class);
                startActivity(intent);
                finish();
                break;
        }
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (SelectCityActivity.SELECT_RESULT_CODE == requestCode && resultCode == SelectCityActivity.SELECT_RESULT_CODE) {
            String cityCode = data.getStringExtra("cityCode");
            String cityId = data.getStringExtra("cityId");
            tvArea.setText(cityCode);
        }
    }


}
